/* bubble_sort.c -- 冒泡排序法 */
#include <stdio.h>
int main()
{
    //冒泡排序
    int a[] = {3, 2, 6, 4, 8, 9, 1, 0, 3, 5, 7, 1};
    int len = sizeof(a)/sizeof(int);    //求出 数组中元素的个数

    int i, j;
    for (size_t i = 0; i < len-1; i++){ //n个元素进行冒泡排序需要进行n-1次循环
        for (size_t j = 0; j < len-1-i; j++){
            if (a[j] > a[j+1]){
                int temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
    }

    for (size_t i = 0; i < len; i++)
    {
        printf("%d ",a[i]);
    }
    printf("\n");
}